]> dgit.raspbian.org Git - gnome-shell.git/commitdiff
gdm/util: Keep track of started services that are currently active
authorMarco Trevisan (Treviño) <mail@3v1n0.net>
Fri, 21 Oct 2022 15:47:15 +0000 (17:47 +0200)
committerMarco Trevisan (Treviño) <mail@3v1n0.net>
Wed, 28 Feb 2024 21:10:23 +0000 (22:10 +0100)
If we have a late activation of a service backend we may need to check
whether it has been already started, and in case it has not, we can try
loading it.

So rely on gdm to see what service has been started, instead of handling
it manually on our side only.

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/2267>

js/gdm/util.js

index 84eb1315ae74d082e841d9d19c47c72211c90bf9..9946b2c610020d06a699f11082901558546a218f 100644 (file)
@@ -112,6 +112,7 @@ export class ShellUserVerifier extends Signals.EventEmitter {
         this._messageQueueTimeoutId = 0;
 
         this._failCounter = 0;
+        this._activeServices = new Set();
         this._unavailableServices = new Set();
 
         this._credentialManagers = {};
@@ -228,6 +229,7 @@ export class ShellUserVerifier extends Signals.EventEmitter {
 
         this._clearUserVerifier();
         this._clearMessageQueue();
+        this._activeServices.clear();
     }
 
     destroy() {
@@ -469,6 +471,7 @@ export class ShellUserVerifier extends Signals.EventEmitter {
             'problem', this._onProblem.bind(this),
             'info-query', this._onInfoQuery.bind(this),
             'secret-info-query', this._onSecretInfoQuery.bind(this),
+            'conversation-started', this._onConversationStarted.bind(this),
             'conversation-stopped', this._onConversationStopped.bind(this),
             'service-unavailable', this._onServiceUnavailable.bind(this),
             'reset', this._onReset.bind(this),
@@ -532,6 +535,7 @@ export class ShellUserVerifier extends Signals.EventEmitter {
     async _startService(serviceName) {
         this._hold.acquire();
         try {
+            this._activeServices.add(serviceName);
             if (this._userName) {
                 await this._userVerifier.call_begin_verification_for_user(
                     serviceName, this._userName, this._cancellable);
@@ -540,6 +544,7 @@ export class ShellUserVerifier extends Signals.EventEmitter {
                     serviceName, this._cancellable);
             }
         } catch (e) {
+            this._activeServices.delete(serviceName);
             if (e.matches(Gio.IOErrorEnum, Gio.IOErrorEnum.CANCELLED))
                 return;
             if (!this.serviceIsForeground(serviceName)) {
@@ -657,6 +662,7 @@ export class ShellUserVerifier extends Signals.EventEmitter {
     _onReset() {
         // Clear previous attempts to authenticate
         this._failCounter = 0;
+        this._activeServices.clear();
         this._unavailableServices.clear();
         this._updateDefaultService();
 
@@ -739,7 +745,13 @@ export class ShellUserVerifier extends Signals.EventEmitter {
             this._queueMessage(serviceName, errorMessage, MessageType.ERROR);
     }
 
+    _onConversationStarted(client, serviceName) {
+        this._activeServices.add(serviceName);
+    }
+
     _onConversationStopped(client, serviceName) {
+        this._activeServices.delete(serviceName);
+
         // If the login failed with the preauthenticated oVirt credentials
         // then discard the credentials and revert to default authentication
         // mechanism.